package com.softeem.controller;

import com.softeem.model.BlogModel;
import com.softeem.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class BlogController {
    @Autowired
    private BlogService blogService;

    @RequestMapping("/blogsMenu")
    @ResponseBody
    public String getBlogService(String tName) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        List<BlogModel> blogs = blogService.getBlog(tName,0,10);
        map.put("msg","");
        map.put("count",blogs.size());
        map.put("data", blogs);
        System.out.println(map);
        return "map";
    }

    @RequestMapping("/index2")
    public String pageToIndex(Map<String,Object> map){
        return "blogsMenu";
    }
}
